package com.gdufe.order.controller;

import java.util.Arrays;
import java.util.Map;

import com.gdufe.order.service.OrderAdminService;
import com.gdufe.order.vo.AdminOrderDetailsVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.gdufe.common.utils.PageUtils;
import com.gdufe.common.utils.R;

/**
 * @author honghu
 * @email 3027708213@qq.com
 * @date 2023-10-28 16:07:06
 */
@RestController
@Slf4j
@RequestMapping("order/admin")
public class OrderAdminController {

    @Autowired
    private OrderAdminService orderAdminService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params) {
        PageUtils page = orderAdminService.queryPage(params);
        return R.ok().put("page", page);
    }


    /**
     * 订单详情
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id) {
        AdminOrderDetailsVO orderDetails = orderAdminService.getOrderDetails(id);
        return R.ok().put("order", orderDetails);
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids) {
        orderAdminService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }

}
